<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>登录页面</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            background-color: #f4f4f4;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            margin: 0;
        }

        .login-container {
            background-color: #fff;
            padding: 20px;
            border-radius: 5px;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
            width: 300px;
        }

        .login-container h2 {
            text-align: center;
            margin-bottom: 20px;
        }

        .form-group {
            margin-bottom: 15px;
        }

        .form-group label {
            display: block;
            margin-bottom: 5px;
        }

        .form-group input {
            width: 100%;
            padding: 10px;
            box-sizing: border-box;
            border: 1px solid #ccc;
            border-radius: 3px;
        }

        .form-group button {
            width: 100%;
            padding: 10px;
            background-color: #007BFF;
            color: #fff;
            border: none;
            border-radius: 3px;
            cursor: pointer;
        }

        .form-group button:hover {
            background-color: #0056b3;
        }
    </style>
    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
</head>
<body>
<div class="login-container">
    <h2>登录</h2>
    <form>
        <div class="form-group">
            <label for="username">用户名:</label>
            <input type="text" id="username" name="username" required>
        </div>
        <div class="form-group">
            <label for="password">密码:</label>
            <input type="password" id="password" name="password" required>
        </div>
        <div class="form-group">
            <button id="submitButton" type="button">登录</button>
        </div>
    </form>
</div>
<script>
    $(document).ready(function () {
        // 假设有一个按钮，点击时触发请求
        $('#submitButton').click(function () {
            $.ajax({
                url: '/shiro/login', // 替换为你的后端接口地址
                method: 'POST', // 使用POST方法
                data: { // 发送的数据
                    username: $('#username').val(),
                    password: $('#password').val()
                },
                success: function (response) {
                    // 成功时，使用alert显示后端返回的数据
                    alert(response);
                },
                error: function (xhr, status, error) {
                    // 处理错误情况
                    alert('请求失败，请检查网络连接或稍后再试。');
                }
            });
        });
    });
</script>
</body>
</html>